package cn.tedu.hotelApi.user.controller;

import cn.tedu.hotelApi.user.pojo.dto.UserParam;
import cn.tedu.hotelApi.user.pojo.dto.UserQuery;
import cn.tedu.hotelApi.user.pojo.vo.UserVO;
import cn.tedu.hotelApi.user.service.UserService;
import cn.tedu.hotelApi.base.response.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController()
@RequestMapping(value = "/v1/user/")
@Slf4j
@Api(tags = "用户模块")
@Validated
public class UserController {
    @Autowired
    UserService userService;

    @ApiOperation("注册修改功能")
    @PostMapping(value = "save")
    public JsonResult saveUser(UserParam userParam){
        log.debug("注册修改功能参数" + userParam);
        userService.saveUser(userParam);
        return JsonResult.ok();
    }
    @ApiOperation("登录功能")
    @PostMapping(value = "login")
    public JsonResult loginUser(UserQuery userQuery){
        log.debug("登录参数" + userQuery);
        UserVO userVO = userService.loginUser(userQuery);
        return JsonResult.ok(userVO);
    }
}
